<template>
  <div class="substate-column-render">
    <span :class="['icon-default', subStateClass]"
          :title="subStateTip"></span>
  </div>
</template>

<script>
  export default {
    name: 'SubStateColumnRenderVue',
    props: {
      record: {
        type: Object,
        default: () => {}
      }
    },
    computed: {
      subStateClass() {
        const { subState } = this.record;
        let backFromId = this.record.backFromId;
        let isBackfrom = false;
        if (backFromId != null || subState == '7' || subState == '16') {
          isBackfrom = true;
        }
        //被回退，处理提交后取回，不显示回退图标
        if (isBackfrom && subState != 13 && subState != 15 && subState != 17 && subState != 6) {
          //被回退并且暂存待办后不显示。被回退图标
          return 'ico16 be_rolledback_16';
        } else if (subState == 12) {
          return 'ico16 viewed_16';
        } else if (subState == 6) {
          return 'ico16 retrieve_16';
        } else {
          if (subState == 15 || subState == 17) {
            if (subState == 17) {
              //指定回退中间节点的时候按照指定回退发起方显示图标
              subState = 15;
            }
          }
          return `ico16 pending${subState}_16`;
        }
      },
      // 是否显示重要程度
      subStateTip() {
        const { subState } = this.record;
        let toolTip = this.$i18n('collaboration.toolTip.label' + subState);
        let backFromId = this.record.backFromId;
        let isBackfrom = false;
        if (backFromId != null || subState == '7' || subState == '16') {
          isBackfrom = true;
        }
        //被回退，处理提交后取回，不显示回退图标
        if (isBackfrom && subState != 13 && subState != 15 && subState != 17 && subState != 6) {
          //被回退并且暂存待办后不显示。被回退图标
          return this.$i18n('collaboration.toolTip.label' + 16);
        } else if (subState == 12) {
          return toolTip;
        } else if (subState == 6) {
          return this.$i18n('common.toolbar.takeBack.label');
        } else {
          if (subState == 15 || subState == 17) {
            toolTip = this.$i18n('common.workflow.specialback.label');
          }
          return toolTip;
        }
      }
    },
    created() {},
    methods: {}
  };
</script>

<style scoped lang="scss">
  .substate-column-render {
    width: 100%;
    position: relative;

    .icon-default {
      font-weight: initial;
    }
  }
</style>
